package alex.game.state
{
	import alex.game.network.Converger;
	import alex.game.updatable.map.BasicMap;
	import alex.game.updatable.plane.BasicPlane;
	import alex.game.util.GameUtil;
	import alex.game.util.Player;
	
	import com.framework.BasicState;
	import com.framework.GG;
	import com.framework.Input;
	import com.framework.util.Log;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class PlayState extends BasicState
	{
		private var map:BasicMap;
		private var me:BasicPlane;
		private var players:Array;
		
		/**
		 * Démarre une game multi après un join game room
		 * @players : liste des jouers de la game room
		 * @map : map de la game
		 * @mode : mode de la game en fonction du type de jeux
		 * 
		 * 
		 **/ 
		public function PlayState()
		{
			
		}
		public function initPlayStateData(players:Array, map:BasicMap):void
		{
			Log.debug(this,"Init play state data");
			this.map = map;
			this.players = players;
			for each(var p:Player in players)
			{
				Log.debug(this, "Username : "+p.username);
			}
		}
		override public function create():void
		{
			super.create();
		}
		override public function destroy():void
		{
			super.destroy();
			GameUtil.players = null;
			GameUtil.map = null;
			GameUtil.gameType = null;
		}
		override public function update():void
		{
			super.update();
			/*map.x = -me.x+((GG.STAGE_WIDTH/this.scaleX)/2);
			map.y = -me.y+((GG.STAGE_HEIGHT/this.scaleY)/2);
			
			var rotFactor:Number = 0;
			if(Input.KEY_LEFT){
				rotFactor -= 0.5;
			}
			if(Input.KEY_RIGHT){
				rotFactor += 0.5;
			}
			if(Input.KEY_UP)
			{
				this.scaleX += 0.005;
				this.scaleY +=0.005;
			}
			if(Input.KEY_DOWN)
			{
				this.scaleX -= 0.005;
				this.scaleY -=0.005;
			}
			me.converger.rot = rotFactor;*/
		}
		
		protected function display():void
		{
			//Ajout de la map
			add(map);
			
			//Debug ajout des avions
			me = new BasicPlane();
			map.addPlane(me);
			
			
		}

	}
}